package com.cloud.bssp.thread;

public class T implements Runnable {
    private /*volatile*/ int count = 100;

    @Override
    public /*synchronized*/ void run() {
        //这里只使用volatile仍然不能保证原子性，因为count--并不是原子操作
        count--;
        System.out.println(Thread.currentThread().getName() + " count = " +
                count);
    }

    public static void main(String[] args) {
        T t = new T();
        for (int i = 0; i < 100; i++) {
            new Thread(t, "THREAD" + i).start();
        }
    }
}